﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace Xin478.CSWork.Common
{
    public class WinForm
    {

        public static void DoThreadSafe(System.Windows.Forms.Control control, MethodInvoker function)
        {
            if (function != null)
            {
                if (control.InvokeRequired)
                {
                    control.Invoke(function);
                }
                else
                {
                    function();
                }
            }
        }

        #region mdiform
        //返回子窗口索引
        public static int OpenedChildIndex(string strChild, Form parentform)
        {
            for (int i = 0; i < parentform.MdiChildren.Length; i++)
            {
                if (parentform.MdiChildren[i].Name == strChild)
                {
                    return i;
                }
            }
            return -1;
        }
        #endregion
    }
}
